﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Data;

namespace Autorent.Desktop.Main.Converters
{
    /// <summary>
    /// Convert Height and Width of free space in grid dinamically to fill this free space
    /// </summary>
    public class VisibilityToStarWidthHeightConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if ((Visibility)value == Visibility.Collapsed)
            {
                return new GridLength(0, GridUnitType.Star);
            }
            else
            {
                return new GridLength(double.Parse(parameter.ToString(), culture), GridUnitType.Star);
            }
        }
       
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return null;
        }
    }
}
